package com.lzb.basic;

import java.util.Collection;
import java.util.List;

public class IProviderListDataProxy<T> implements IProviderListData<T> {

    private static class IProviderListDataProxyHolder {
        private static IProviderListDataProxy sManager = new IProviderListDataProxy();
    }

    public static IProviderListDataProxy getInstance() {
        return IProviderListDataProxyHolder.sManager;
    }
    private IProviderListData<T> mProxy;

    /**
     * 设置数据处理具体实例
     * @param proxy 数据处理代理对象
     */
    public void setListDataProxy(IProviderListData proxy){
        mProxy = proxy;
    }

    private IProviderListDataProxy(){
        mProxy = new IProviderListDataDefault<>();
    }

    @Override
    public Collection<T> setList(Collection<T> list, int spanCount) {
        return mProxy.setList(list,spanCount);
    }

    @Override
    public Collection<T> addData(Collection<T> list, int spanCount) {
        return mProxy.addData(list,spanCount);
    }
    @Override
    public List<T> getData(List<T> list) {
        return mProxy.getData(list);
    }
}

class IProviderListDataDefault<T> implements IProviderListData<T>{
     @Override
     public Collection<T> setList(Collection<T> list, int spanCount) {
         return list;
     }

     @Override
     public Collection<T> addData(Collection<T> list, int spanCount) {
         return list;
     }

    @Override
    public List<T> getData(List<T> list) {
        return list;
    }
 }

